<?php

error_reporting(E_ALL);

/**
 * ECommerce - class.ModeloProveedor.php
 *
 * $Id$
 *
 * This file is part of ECommerce.
 *
 * Automatically generated on 17.11.2011, 16:45:29 with ArgoUML PHP module 
 * (last revised $Date: 2010-01-12 20:14:42 +0100 (Tue, 12 Jan 2010) $)
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/* user defined includes */
// section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001392-includes begin
require_once('class.Conexion.php');
// section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001392-includes end

/* user defined constants */
// section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001392-constants begin
// section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001392-constants end

/**
 * Short description of class ModeloProveedor
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class ModeloProveedor
Extends Conexion
{
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    // --- OPERATIONS ---

    /**
     * Short description of method getAllRows
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return void
     */
    public function getAllRows()
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001393 begin
        $sql = "SELECT * FROM proveedores";
		return $this->ejecutarQuery($sql);
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001393 end
    }

    /**
     * Short description of method searchById
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return void
     */
    public function searchById($id)
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001395 begin
        $sql = "SELECT * FROM proveedores WHERE idproveedor = '$id'";
		$row0 = $this->ejecutarQuery($sql);
		return $row0[0];
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001395 end
    }

    /**
     * Short description of method InsertRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  datos
     * @return void
     */
    public function InsertRow($datos)
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001397 begin
        $proveedor = @$datos['proveedor'];
        $descripcion = @$datos['descripcion'];
		$telefono = @$datos['telefono'];
		$sql = "INSERT INTO proveedores (proveedor,descripcion,telefono) VALUES ('$proveedor','$descripcion','$telefono')";
		$this->ejecutarQuery($sql);	
		return mysql_insert_id();
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:0000000000001397 end
    }

    /**
     * Short description of method updateRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  datos
     * @return void
     */
    public function updateRow($datos)
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:000000000000139B begin
        $sql= "
			UPDATE proveedores SET 
				proveedor = '".@$datos[proveedor]."',
				descripcion = '".@$datos[descripcion]."',
				telefono = '".@$datos[telefono]."'
				WHERE idproveedor = '".@$datos['idproveedor']."'
		";
		$this->ejecutarQuery($sql);
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:000000000000139B end
    }

    /**
     * Short description of method deleteRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return void
     */
    public function deleteRow($id)
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:000000000000139E begin
        $sql= "DELETE FROM proveedores WHERE idproveedor = $id";
		$this->ejecutarQuery($sql);
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:000000000000139E end
    }

    /**
     * Short description of method getRowsByNombre
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  nombre
     * @return void
     */
    public function getRowsByNombre($nombre)
    {
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013A1 begin
        $sql = "SELECT * FROM proveedores WHERE proveedor LIKE '%".$nombre."%'";
		return $this->ejecutarQuery($sql);
        // section -64--88-56-1-6e863ffe:133b3c3afe4:-8000:00000000000013A1 end
    }

} /* end of class ModeloProveedor */

?>